<?php
  // no direct access
  defined( '_JEXEC' ) or die( 'Restricted access' );
  jimport( 'joomla.application.component.view');
  
  class VenueViewVenue extends JView
  {              
    var $_name = "venue";
  
    function display()
    { 
      $this->displayList();
    }
    
    function displayList()
    {
      /* sorting */
      $state =& $this->get( 'state' );
      $lists['order_Dir'] = $state->get($this->_name . 'filter_order_Dir' );
            $lists['order']     = $state->get($this->_name . 'filter_order' );
            $this->assignRef('lists', $lists);    
    
      $venue  = $this->getModel('venue');
      $pic    = $this->getModel('pic');
      
      $venues = $this->get('ListData');
      for($i=0; $i<count($venues); $i++){
      
        if($venues[$i]->pic_id > 0){
          $pic_obj = $pic->get($venues[$i]->pic_id);
          $venues[$i]->pic = $pic_obj;
        }
        
      }
      $this->assign('venues', $venues);
      $pagination = $this->get('Pagination');
      $this->assign('pagination', $pagination);
      
      JToolBarHelper::title( JText::_( 'Venues' ), 'generic.png' );  
      
      JToolBarHelper::publishList();
      JToolBarHelper::unpublishList();
      JToolBarHelper::addNew();
      JToolBarHelper::editList();
      JToolBarHelper::deleteList();
      
      PBNYHelper::createMenu();
      
      parent::display("list");    
    }
    
    function displayAdd()
    {  
      $editor =& JFactory::getEditor();
      $this->assign('editor', $editor);
      
      JToolBarHelper::title( JText::_( 'Add Venue' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
    
    function displayEdit()
    {    
      $cids = JRequest::getVar('cid', null, 'default', 'array' );
      
      $venue = $this->getModel('venue');
      $pic   = $this->getModel('pic');
      
      $d_venue = $venue->get($cids[0], true);
      $this->assign('venue', $d_venue);
      
      $d_pic   = $pic->get($d_venue->pic_id);
      $this->assign('pic', $d_pic);
      
      $editor =& JFactory::getEditor();
      $this->assign('editor', $editor);  

      JToolBarHelper::title( JText::_( 'Edit Venue' ), 'generic.png' );
      JToolBarHelper::save();
      JToolBarHelper::cancel();  

      parent::display("edit");
    }    
  }
?>